home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 SRC / Mac / Modules / qt / qtscan.py < prev    next >
Text File  |  1996-04-12  |  3KB  |  114 lines

  1. # Scan an Apple header file, generating a Python file of generator calls.
  2.  
  3. import addpack
  4. addpack.addpack(':tools:bgen:bgen')
  5. from scantools import Scanner
  6. from bgenlocations import TOOLBOXDIR
  7.  
  8. LONG = "QuickTime"
  9. SHORT = "qt"
  10. OBJECTS = ("Movie", "Track", "Media", "UserData", "TimeBase", "MovieController")
  11.  
  12. def main():
  13.     input = "Movies.h"
  14.     output = SHORT + "gen.py"
  15.     defsoutput = TOOLBOXDIR + LONG + ".py"
  16.     scanner = MyScanner(input, output, defsoutput)
  17.     scanner.scan()
  18.     scanner.close()
  19.     print "=== Done scanning and generating, now importing the generated code... ==="
  20.     exec "import " + SHORT + "support"
  21.     print "=== Done.  It's up to you to compile it now! ==="
  22.  
  23. class MyScanner(Scanner):
  24.  
  25.     def destination(self, type, name, arglist):
  26.         classname = "Function"
  27.         listname = "functions"
  28.         if arglist:
  29.             t, n, m = arglist[0]
  30.             if t in OBJECTS and m == "InMode":
  31.                 classname = "Method"
  32.                 listname = t + "_methods"
  33.         return classname, listname
  34.  
  35.     def makeblacklistnames(self):
  36.         return [
  37.             "DisposeMovie",        # Done on python-object disposal
  38.             "DisposeMovieTrack",    # ditto
  39.             "DisposeTrackMedia",    # ditto
  40.             "DisposeUserData",        # ditto
  41.             "DisposeTimeBase",        # ditto
  42.             "DisposeMovieController", # ditto
  43.             "GetMovieCreationTime",    # type "unsigned long" in C, inparseable
  44.             "GetMovieModificationTime",    # Ditto
  45.             "GetTrackCreationTime",        # ditto
  46.             "GetTrackModificationTime",    # Ditto
  47.             "GetMediaCreationTime",        # ditto
  48.             "GetMediaModificationTime",    # Ditto
  49.             # The following 4 use 'void *' in an uncontrolled way
  50.             # TBD when I've read the manual...
  51.             "GetUserDataItem",
  52.             "SetUserDataItem",
  53.             "SetTextSampleData",
  54.             # bgen gets the argument in/out wrong..
  55.             "AddTextSample",
  56.             "AddTESample",
  57.             "AddHiliteSample",
  58.             "HiliteTextSample",
  59.             ]
  60.  
  61.     def makeblacklisttypes(self):
  62.         return [
  63.             # I don't think we want to do these
  64.             "QTSyncTaskPtr",
  65.             # We dont do callbacks yet, so no need for these
  66.             "QTCallBack",
  67.             # Skipped for now, due to laziness
  68.             "TimeRecord",
  69.             "TimeRecord_ptr",
  70.             "TrackEditState",
  71.             "MovieEditState",
  72.             "MatrixRecord",
  73.             "MatrixRecord_ptr",
  74.             "SampleReferencePtr",
  75. #            "SampleDescription",
  76. #            "SoundDescription",
  77. #            "TextDescription",
  78. #            "MusicDescription",
  79.             # I dont know yet how to do these.
  80.             "CGrafPtr",
  81.             "GDHandle",
  82.             # Routine pointers, not yet.
  83.             "MoviesErrorUPP",
  84.             "MoviePreviewCallOutUPP",
  85.             "MovieDrawingCompleteUPP",
  86.             "QTCallBackUPP",
  87.             "TextMediaUPP",
  88.             "MovieProgressUPP",
  89.             "MovieRgnCoverUPP",
  90.             "MCActionFilterUPP",
  91.             "MCActionFilterWithRefConUPP",
  92.             "GetMovieUPP",
  93.             "ModalFilterUPP",
  94.             ]
  95.  
  96.     def makerepairinstructions(self):
  97.         return [
  98.             ([('FSSpec', '*', 'OutMode')], [('FSSpec_ptr', '*', 'InMode')]),
  99.             
  100.             # Movie controller creation
  101.             ([('ComponentInstance', 'NewMovieController', 'ReturnMode')],
  102.              [('MovieController', '*', 'ReturnMode')]),
  103.              
  104.             # NewMovieFromFile
  105.             ([('short', 'resId', 'OutMode'), ('StringPtr', 'resName', 'InMode')],
  106.              [('dummyshortptr', 'resId', 'InMode'), ('dummyStringPtr', 'resName', 'InMode')]),
  107.              
  108.             # MCDoAction
  109.             ([('void', 'params', 'OutMode')], [('mcactionparams', 'params', 'InMode')]),
  110.             ]
  111.             
  112. if __name__ == "__main__":
  113.     main()
  114.